<?php
	require_once './Tool/DB/SqlDBManager.class.php';
	$sqlDBManager= new SqlDBManager();

	$username = $_SESSION['username'];
	$nric = $_POST['btnSO'];

	$sql = "Select * from attendancerecord WHERE NRIC=? AND date(SignInTimeStamp)=CURDATE() AND Status=?";
	$parameters=array($nric,'Verified');
	$res=$sqlDBManager->queryRows($sql,$parameters);

	if(!empty($res)){
		$sql = "UPDATE attendancerecord SET SignOutTimeStamp=NOW(),AuditSignOut=? WHERE NRIC=? AND DATE(SignInTimeStamp)= CURDATE()";
		$parameters=array($username,$nric);
		$res=$sqlDBManager->execute_dml($sql,$parameters);
	}else{
		print '<script type="text/javascript">';
		print 'alert("Please verify the attendance first.")';
		print '</script>';
	}
	include_once('Attendance/getattendance.php');
?>